.. _cannot-use-"parent"-when-no-class-scope-is-active: Cannot use "parent" when no class scope is active ------------------------------------------------- .. meta:: :description: Cannot use "parent" when no class scope is active: ``parent`` is a keyword that represent the parent class of the current class. :og:image: https://php-errors.readthedocs.io/en/latest/_static/logo.png :og:type: article :og:title: Cannot use "parent" when no class scope is active :og:description: ``parent`` is a keyword that represent the parent class of the current class :og:url: https://php-errors.readthedocs.io/en/latest/messages/cannot-use-%22parent%22-when-no-class-scope-is-active.html :og:locale: en :twitter:card: summary_large_image :twitter:site: @exakat :twitter:title: Cannot use "parent" when no class scope is active :twitter:description: Cannot use "parent" when no class scope is active: ``parent`` is a keyword that represent the parent class of the current class :twitter:creator: @exakat :twitter:image:src: https://php-errors.readthedocs.io/en/latest/_static/logo.png .. raw:: html Description ___________ ``parent`` is a keyword that represent the parent class of the current class. When the code is not located inside a class, it cannot have a parent, and so, is forbidden. Example _______ .. code-block:: php Solutions _________ + Convert the function into a method, in a class with a parent. + Convert the function into a closure, and assign it a to an object of a class with a parent.